<?php //strip
/**
 * Class that representing single member.
 * 
 * @package odReservationsWpPlugin
 * @subpackage odReservationsWpPlugin_Models
 * @author Ondrej Donek <ondrejd@gmail.com>
 */
class odReservationsWpPlugin_Models_Member_Item
{
  protected $mId = 0;
  protected $mWpUserId = 0;
  protected $mStreet = '';
  protected $mTown = '';
  protected $mZip = '';
  protected $mPhone = '';
  protected $mMemberNum = '';
  protected $mCreditsOrdered = 0;
  protected $mCreditsLeft = 0;
  protected $mCreated = '';
  protected $mDeleted = false;

  /**
   * Constructor of class odReservationsWpPlugin_Models_Member_Item.
   * 
   * @param array $aValues Should be array like one provided by model class.
   * @return void
   */
  public function __construct($aValues = null)
  {
    if(is_array($aValues)) {
      $this->mId = ((array_key_exists('ID', $aValues)) ? $aValues['ID'] : 0);
      $this->mWpUserId = ((array_key_exists('wp_user_ID', $aValues)) ? $aValues['wp_user_ID'] : 0);
      $this->mStreet = ((array_key_exists('street', $aValues)) ? $aValues['street'] : '');
      $this->mTown = ((array_key_exists('town', $aValues)) ? $aValues['town'] : '');
      $this->mZip = ((array_key_exists('zip', $aValues)) ? $aValues['zip'] : '');
      $this->mPhone = ((array_key_exists('phone', $aValues)) ? $aValues['phone'] : '');
      $this->mMemberNum = ((array_key_exists('member_num', $aValues)) ? $aValues['member_num'] : '');
      $this->mCreditsOrdered = ((array_key_exists('credits_ordered', $aValues)) ? $aValues['credits_ordered'] : 0);
      $this->mCreditsLeft = ((array_key_exists('credits_left', $aValues)) ? $aValues['credits_left'] : 0);
      $this->mCreated = ((array_key_exists('created', $aValues)) ? $aValues['created'] : date('Y-m-d H:i:s'));
      $this->mDeleted = ((array_key_exists('deleted', $aValues)) ? ((intval($aValues['deleted']) == 1) ? true : false) : false);
    }
  }
  
  /**
   * Getter for class properties.
   * 
   * @param string $aKey
   * @return mixed
   * @throws Exception Whenever <code>$aKey</code> was not recognized.
   */
  public function __get($aKey) 
  {
    switch($aKey) {
      case 'ID': return $this->_getId(); break;
      case 'wp_user_ID': return $this->_getMemberId(); break;
      case 'street': return $this->_getMemberNum(); break;
      case 'town': return $this->_getMemberName(); break;
      case 'zip': return $this->_getPlaygroundId(); break;
      case 'phone': return $this->_getPlaygroundName(); break;
      case 'member_num': return $this->_getPlaymates(); break;
      case 'credits_ordered': return $this->_getStart(); break;
      case 'credits_left': return $this->_getCancelled(); break;
      case 'created': return $this->_getCancelledWhen(); break;
      case 'deleted': return $this->_getDeleted(); break;
      default:
        throw new Exception('Unrecognized property key!');
        break;
    }
  }
  
  public function getId() { return $this->mId; }
  public function getWpUserId() { return $this->mWpUserId; }
  public function getStreet() { return $this->mStreet; }
  public function getTown() { return $this->mTown; }
  public function getZip() { return $this->mZip; }
  public function getPhone() { return $this->mPhone; }
  public function getMemberNum() { return $this->mMemberNum; }
  public function getCreditsOrdered() { return $this->mCreditsOrdered; }
  public function getCreditsLeft() { return $this->mCreditsLeft; }
  public function getCreated() { return $this->mCreated; }
  public function getDeleted() { return $this->mDeleted; }
  
  /**
   * Setter for class properties.
   * 
   * @param string $aKey
   * @param mixed $aValue
   * @return void
   * @throw Exception Whenever <code>$aKey</code> was not recognized.
   */
  public function __set($aKey, $aValue)
  {
    switch($aKey) {
      case 'ID': return $this->_setId($aValue); break;
      case 'member_ID': return $this->_setMemberId($aValue); break;
      case 'playground_ID': return $this->_setPlaygroundId($aValue); break;
      case 'playmates': return $this->_setPlaymates($aValue); break;
      case 'start': return $this->_setStart($aValue); break;
      case 'cancelled': return $this->_setCancelled($aValue); break;
      case 'cancelled_when': return $this->_setCancelledWhen($aValue); break;
      case 'note': return $this->_setNote($aValue); break;
      case 'member_num':
      case 'member_name':
      case 'playground_name':
        throw new Exception('Value of selected property is readonly!');
        break;
      default:
        throw new Exception('Unrecognized property key!');
        break;
    }
  }
  
  public function setId($aValue) { $this->mId = $aValue; }
  public function setMemberId($aValue) { $this->mMemberId = $aValue; }
  public function setPlaygroundId($aValue) { $this->mPlaygroundId = $aValue; }
  public function setPlaymates($aValue) { $this->mPlaymates = $aValue; }
  public function setStart($aValue) { $this->mStart = $aValue; }
  public function setCancelled($aValue) { $this->mCancelled = $aValue; }
  public function setCancelledWhen($aValue) { $this->mCancelledWhen = $aValue; }
  public function setNote($aValue) { $this->mNote = $aValue; }
  
} // End of odReservationsWpPlugin_Models_Reservation_Item
